/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AgregaMed.java
 *
 * Created on 27-11-2010, 01:45:21 AM
 */
package vista;

import conexionBaseDatos.InsertInputData;

/**
 *
 * @author David Vallejos A
 */
public class AgregaMed extends javax.swing.JFrame {

    /** Creates new form AgregaMed */
    private String med1 = "";
    private String lab1 = "";
    private int dosis1;
    private String med2 = "";
    private String lab2 = "";
    private int dosis2;
    private String med3 = "";
    private String lab3 = "";
    private int dosis3;
    private String med4 = "";
    private String lab4 = "";
    private int dosis4;
    private String med5 = "";
    private String lab5 = "";
    private int dosis5;
    private String nombrePaciente = "";
    String rutFinal = "";

    public AgregaMed() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToggleButton1 = new javax.swing.JToggleButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        cajaMed1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        cajaLab1 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        cajaDosis1 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        cajaMed2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        cajaMed3 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        cajaMed4 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        cajaLab2 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        cajaLab3 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        cajaLab4 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        cajaDosis2 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        cajaDosis3 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        cajaDosis4 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        cajaMed5 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        cajaLab5 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        cajaDosis5 = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();

        jToggleButton1.setText("jToggleButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Agregar Medicamentos");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Puede agregar como máximo 5 medicamentos contando el anterior ya ingresado");

        jLabel2.setText("Medicamento n°1:");

        jLabel3.setText("Laboratorio:");

        jLabel4.setText("Dosis:");

        jLabel5.setText("Medicamento n°2:");

        jLabel6.setText("Medicamento n°3:");

        jLabel7.setText("Medicamento n°4:");

        jLabel8.setText("Laboratorio:");

        jLabel9.setText("Laboratorio:");

        jLabel10.setText("Laboratorio:");

        jLabel11.setText("Dosis:");

        jLabel12.setText("Dosis:");

        jLabel13.setText("Dosis:");

        jButton1.setText("aceptar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("volver");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel14.setText("Medicamento n°5:");

        jLabel15.setText("Laboratorio:");

        jLabel16.setText("Dosis:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cajaMed2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 221, Short.MAX_VALUE)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cajaDosis2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cajaMed3, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 221, Short.MAX_VALUE)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cajaDosis3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cajaMed4, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9)
                            .addComponent(jLabel10)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(cajaLab5)
                            .addComponent(cajaLab1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                            .addComponent(cajaLab2, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cajaLab3, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cajaLab4, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 19, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cajaDosis4, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cajaDosis5, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 492, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cajaMed1, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 221, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cajaDosis1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(76, 76, 76))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(352, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton2)
                .addGap(58, 58, 58))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cajaMed5, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(364, Short.MAX_VALUE))
            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(cajaMed1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cajaDosis1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(cajaLab1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(cajaMed2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cajaDosis2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(cajaLab2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6)
                    .addComponent(cajaMed3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cajaDosis3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel12)
                        .addComponent(cajaLab3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel9)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cajaMed4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cajaDosis4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13)
                        .addComponent(cajaLab4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14)
                        .addComponent(cajaMed5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel15)
                        .addComponent(cajaLab5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cajaDosis5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel16)))
                .addGap(27, 27, 27)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(29, 29, 29))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 341, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        VentanaPrincipal volver = new VentanaPrincipal();
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        this.ingresaRestoMedicamentos();
    }//GEN-LAST:event_jButton1ActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField cajaDosis1;
    private javax.swing.JTextField cajaDosis2;
    private javax.swing.JTextField cajaDosis3;
    private javax.swing.JTextField cajaDosis4;
    private javax.swing.JTextField cajaDosis5;
    private javax.swing.JTextField cajaLab1;
    private javax.swing.JTextField cajaLab2;
    private javax.swing.JTextField cajaLab3;
    private javax.swing.JTextField cajaLab4;
    private javax.swing.JTextField cajaLab5;
    private javax.swing.JTextField cajaMed1;
    private javax.swing.JTextField cajaMed2;
    private javax.swing.JTextField cajaMed3;
    private javax.swing.JTextField cajaMed4;
    private javax.swing.JTextField cajaMed5;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration//GEN-END:variables

    public void ObitieneRut(String rut) {

        rutFinal = rut;
    }

    public void obtieneMed1(String med) {

        med1 = med;
    }

    public void obtieneLab1(String lab) {

        lab1 = lab;
    }

    public void obtieneDosis1(int dosis) {

        dosis1 = dosis;
    }

    public String getRutFinal() {

        return rutFinal;
    }

    public int getDosis1() {
        return dosis1;
    }

    public String getLab1() {
        return lab1;
    }

    public String getMed1() {
        return med1;
    }

    public void obtieneNombrePaciente(String nombreMasc) {
        this.nombrePaciente = nombreMasc;
    }

    public String getNombrePaciente() {
        return nombrePaciente;
    }

    public void ingresaRestoMedicamentos() {

        String RutBD = getRutFinal();
        String nombrePacienteBD = getNombrePaciente();

        med1 = cajaMed1.getText();
        lab1 = cajaLab1.getText();
        String dosis1Texto = cajaDosis1.getText();

        if ((med1.equals("")) && (lab1.equals("")) && (dosis1Texto.equals(""))) {
            med1 = "SIN MEDICAMENTOS";
            lab1 = "SIN MEDICAMENTOS";
            dosis1 = 0;

            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med1, lab1, dosis1, nombrePacienteBD);

        } else {

            dosis1 = Integer.parseInt(dosis1Texto);
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med1, lab1, dosis1, nombrePaciente);
        }

        med2 = cajaMed2.getText();
        lab2 = cajaLab2.getText();
        String dosis2Texto = cajaDosis2.getText();

        if ((med2.equals("")) && (lab2.equals("")) && (dosis2Texto.equals(""))) {
            med2 = "SIN MEDICAMENTOS";
            lab2 = "SIN MEDICAMENTOS";
            dosis2 = 0;

            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med2, lab2, dosis2, nombrePaciente);

        } else {

            dosis2 = Integer.parseInt(dosis2Texto);
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med2, lab2, dosis2, nombrePaciente);
        }

        med3 = cajaMed3.getText();
        lab3 = cajaLab3.getText();
        String dosis3Texto = cajaDosis3.getText();

        if ((med3.equals("")) && (lab3.equals("")) && (dosis3Texto.equals(""))) {
            med3 = "SIN MEDICAMENTOS";
            lab3 = "SIN MEDICAMENTOS";
            dosis3 = 0;
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med3, lab3, dosis3, nombrePaciente);

        } else {

            dosis3 = Integer.parseInt(dosis3Texto);
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med3, lab3, dosis3, nombrePaciente);
        }

        med4 = cajaMed4.getText();
        lab4 = cajaLab4.getText();
        String dosis4Texto = cajaDosis4.getText();

        if ((med4.equals("")) && (lab4.equals("")) && (dosis4Texto.equals(""))) {
            med4 = "SIN MEDICAMENTOS";
            lab4 = "SIN MEDICAMENTOS";
            dosis4 = 0;
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med4, lab4, dosis4, nombrePaciente);

        } else {

            dosis4 = Integer.parseInt(dosis4Texto);
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med4, lab4, dosis4, nombrePaciente);
        }

        med5 = cajaMed5.getText();
        lab5 = cajaLab5.getText();
        String dosis5Texto = cajaDosis5.getText();

        if ((med5.equals("")) && (lab5.equals("")) && (dosis5Texto.equals(""))) {
            med5 = "SIN MEDICAMENTOS";
            lab5 = "SIN MEDICAMENTOS";
            dosis5 = 0;
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med5, lab5, dosis5, nombrePaciente);

        } else {

            dosis5 = Integer.parseInt(dosis5Texto);
            InsertInputData.InsertarDatosTablaMedicamento(RutBD, med5, lab5, dosis5, nombrePaciente);
        }
        VentanaPrincipal volver = new VentanaPrincipal();
        this.dispose();
    }

    public void noIngresaMed(String rut, String nombre) {

        med1 = "SIN MEDICAMENTOS";
        lab1 = "SIN MEDICAMENTOS";
        dosis1 = 0;
        InsertInputData.InsertarDatosTablaMedicamento(rut, med1, lab1, dosis1, nombre);

        med2 = "SIN MEDICAMENTOS";
        lab2 = "SIN MEDICAMENTOS";
        dosis2 = 0;

        InsertInputData.InsertarDatosTablaMedicamento(rut, med2, lab2, dosis2, nombre);

        med3 = "SIN MEDICAMENTOS";
        lab3 = "SIN MEDICAMENTOS";
        dosis3 = 0;

        InsertInputData.InsertarDatosTablaMedicamento(rut, med3, lab3, dosis3, nombre);

        med4 = "SIN MEDICAMENTOS";
        lab4 = "SIN MEDICAMENTOS";
        dosis4 = 0;

        InsertInputData.InsertarDatosTablaMedicamento(rut, med4, lab4, dosis4, nombre);

        med5 = "SIN MEDICAMENTOS";
        lab5 = "SIN MEDICAMENTOS";
        dosis5 = 0;

        InsertInputData.InsertarDatosTablaMedicamento(rut, med5, lab5, dosis5, nombre);
    }
}
